<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/common/include/page.jsp"%>
<jsp:useBean id="pojo" class="com.liu.users.pojo.AUsers"/>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<title>用户列表 - 前台 - 用户中心</title>
		<%@include file="/common/include/title.jsp"%>
	</head>
	<body>
		<%@include file="/common/include/header.jsp"%>
		<!-- 网页的主体部分 -->
		<div class="container">
			<div class="row">
				<div class="col-md-11 col-sm-offset-1">
					<h2 class="sub-header">用户列表</h2>
	
					<form action="${rootPath}/head/users/usersList" method="post" class="form-inline">
						<label for="keyword">关键字:</label> 
							<input type="${requestScope.keyword }" name="keyword" value="" class="form-control mr-sm-2"> 
						<label>状态:</label>
						<select name="status" class="form-control">
							<option value="">请选择</option>
							<c:forEach items="${pojo.enumsMap}" var="me" varStatus="stat">
								<%-- 
									fn:split:拆分
									fn:startsWith:以什么什么开头
								--%>
								<c:set value="${fn:split(me.key,'-') }" var="keys"/>
								<c:if test="${fn:startsWith(keys[0],'STATUS_')}">
									<option value="${keys[1] }" ${requestScope.status == keys[1] ? 'selected': '' }>${me.value}</option>
								</c:if>
							</c:forEach>
						</select>
						<label>邮箱状态:</label>
						<select name="emailStatus" class="form-control">
							<option value="">请选择</option>
							<c:forEach items="${pojo.enumsMap }" var="me" varStatus="stat">
								<%-- 
									fn:split:拆分
									fn:startsWith:以什么什么开头
								--%>
								<c:set value="${fn:split(me.key,'-') }" var="keys"/>
								<c:if test="${fn:startsWith(keys[0],'EMAILSTATUS_')}">
									<option value="${keys[1] }" ${requestScope.emailStatus == keys[1] ? 'selected': '' }>${me.value}</option>
								</c:if>
							</c:forEach>
						</select>
						<label for="email">更新时间:</label>
						<input type="text" name="st" value="${requestScope.st }" readonly="true" class="form-control mr-sm-2" 
							onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate"/>
						
						<input type="text" name="ed" value="${requestScope.ed }" readonly="true" class="form-control mr-sm-2" 
							onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate"/>
						<input type="submit" class="btn btn-primary" value="搜索">
					</form>
				</div>
				<div class="col-md-11 col-sm-offset-1">
					<div class="table-responsive mt-2">
						<table class="table table-striped table-hover">
							<thead>
								<tr>
									<th>序号</th>
									<th>Id</th>
									<th>地区</th>
									<th>邮箱</th>
									<th>昵称</th>
									<th title="邮箱状态">邮状</th>
									<th>状态</th>
									<th>注册时间</th>
									<th>上次登陆时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${requestScope.list }" var="listTemp" varStatus="stat">
									<tr>
										<td>${stat.count }</td>
										<td>${listTemp.id }</td>
										<td>${listTemp.region.name }</td>
										<td title="${listTemp.email }">
											<a href="${rootPath }/head/users/usersUpdate?id=${listTemp.id}" target="_blank">
												${fn:substring(listTemp.email,0,strLen) }
											</a>
										</td>
										<td>${listTemp.nickName }</td>
										<td>${listTemp.emailStatusStr }</td>
										<td>${listTemp.statusStr}</td>
										<td><fmt:formatDate value="${listTemp.createTime }" pattern="${dateTimeFormat }"/></td>
										<td><fmt:formatDate value="${listTemp.lastLoginTime }" pattern="${dateTimeFormat }"/></td>
										<td>
											<a href="${rootPath }/head/users/usersUpdate?operType=updateInfo&id=${listTemp.id}" target="_blank" class="btn btn-primary">
												更新
											</a>
											<a href="${rootPath }/head/users/usersUpdate?operType=updatePhoto&id=${listTemp.id}" target="_blank" class="btn btn-primary">
												修改头像
											</a>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
				<div class="col-md-11 col-sm-offset-1">
					<form id="pageForm" action="${rootPath }/head/users/usersList"
						method="post" class="form-inline col-md-11 col-sm-offset-1">
						<input type="hidden" name="keyword" value="${requestScope.keyword }">
						<input type="hidden" name="status" value="${requestScope.status }">
						<input type="hidden" name="emailStatus" value="${requestScope.emailStatus }">
						<input type="hidden" name="st" value="${requestScope.st }">
						<input type="hidden" name="ed" value="${requestScope.ed }">							
						<nav aria-label="Page navigation example">
							<ul class="pagination justify-content-end">
								<li class="page-item">
									<a href="#" class="page-link" onclick="return pageFormSubmit('pageForm','1','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSize')">
										<span>首页</span>
									</a>
								</li>
								<li class="page-item">
									<a href="#" class="page-link" onclick="return pageFormSubmit('pageForm','${requestScope.pageInfoUtil.prePage }','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSize')">
										<span>上一页</span>
									</a>
								</li>
								<li class="page-item">
									<a href="#" class="page-link" onclick="return pageFormSubmit('pageForm','${requestScope.pageInfoUtil.nextPage }','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSize')">
										<span>下一页</span>
									</a>
								</li>
								<li class="page-item">
									<a href="#" class="page-link" onclick="return pageFormSubmit('pageForm','${requestScope.pageInfoUtil.totalPage }','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSize')">
										<span>尾页</span>
									</a>
								</li>
								<li class="page-item">共${requestScope.pageInfoUtil.totalPage }页,共${requestScope.pageInfoUtil.totalRecord }条</li>
								<li class="page-item">
									第<input type="text" id="currentPage" name="currentPage" class="form-control" value="${requestScope.pageInfoUtil.currentPage }" size="5" maxlength="5"/>页
								</li>
								<li class="page-item">
									每页<input type="text" id="pageSize" name="pageSize" class="form-control" value="${requestScope.pageInfoUtil.pageSize }" size="5" maxlength="5"/>条
								</li>
								<li class="page-item"><input type="submit" value="GO" class="form-control btn btn-primary"/></li>
							</ul>
						</nav>
					</form>
				</div>
			</div>
		</div>
		<%@include file="/common/include/footer.jsp"%>
	</body>
</html>